/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tencent.tendon.convert.json;

/**
 *
 * @author nbzhang
 */
public final class JsonReferDecoder extends JsonDecoder<Object> {

    private static final JsonReferDecoder instance = new JsonReferDecoder();

    private JsonReferDecoder() {
        super(Object.class);
        this.simpled = true;
    }

    public static JsonReferDecoder getInstance() {
        return instance;
    }

    @Override
    public Object convertFrom(final JsonReader in) {
        JsonDeHandle handle = in.readField(JsonDeHandle.NULL);
        in.checkColon();
        if (handle != JsonDeHandle.REFER) {
            in.skipValue();
            return null;
        }
        return convertReferFrom(in);
    }

    public Object convertReferFrom(final JsonReader in) {
        char[] vs = in.readValue();
        in.readChar(); //读掉 '}'
        return in.stackOf(vs.length);
    }
}
